<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript" src="js/jquery.js"></script>
        <title></title>
    </head>
    <body>
	<div>
	
	</div>
        <a href="javascript:  arr.add(2);">+</a>
        <a href="javascript:arr.minus(1);">-</a>
    </body>
</html>
<script>
    var result = { a: 0, b: 0, c: 0, d: 0, e: 0 };
    $(function() {
	   arr.goods_push(8);
	   //ert(arr.category.8);
    });

	/*
		#######属性########

		rname：英雄名
		nickname：英雄昵称
		rimg:英雄人物图片地址
		type:攻击类型  1-近战 2-远程
		range：攻击距离
		rattribute:主属性 1-力量 2-敏捷 3-智力
		hp：生命值
		hp_r：生命回复
		mp：法力值
		mp_r:法力回复
		armor:护甲
		m_armor:魔抗
		movespeed：移动速度
		attackspeed:攻击速度
		attack_damage:攻击力
		strength:力量
		agility:敏捷
		intelligence:智力
		strength_gain:力量成长
		agility_gain:敏捷成长
		intelli_gain:智力成长
		base_movespeed:基础移动速度
		base_damage:基础攻击力
		base_armor:基础护甲
		base_m_armor:基础磨抗
		base_attack_cooldown:基础基础攻击间隔
		base_strength:基础力量
		base_agility:基础敏捷
		base_intelligence:基础敏捷
		
		gname:道具名
		gimg:道具图片地址
		formula:配方
		gattribute:属性  (属性名跟人物角色名的属性名一致 如智力-intelligence,等等)
		effect:效果｛
				uniq:{
						name:'抗魔：魔抗+1/2/3'  唯一的属性描述
						value:[1,2,3]	对应等级的值
					},
				up:false, 是否可以升级 默认false
				up_describe:"物品升级描述",
				grade: 物品等级 默认为1
		｝
		pay:价格
		
		
	*/

    var arr = {
        role: {
			1: {
                rname: "翡翠灵女",
				nickname:"艾露娜",
				rimg:"images/yx1.png",
                type:2,
                range:600,
                rattribute:3,
				strength_gain:2,
				agility_gain:1.8,
				intelli_gain:2.8,
				base_movespeed:300,
				base_damage:28,
				base_armor:0,
				base_m_armor:5.5,
				base_attack_cooldown:1550,
				base_strength:16,
				base_agility:18,
				base_intelligence:22
            },
            2: {
                rname: "死亡天使",
				nickname:"萨默艾尔",
				rimg:"images/yx2.png",
                type:1,
                range:600,
                rattribute:1,
				strength_gain:2.7,
				agility_gain:1.5,
				intelli_gain:2,
				base_movespeed:300,
				base_damage:32,
				base_armor:2,
				base_m_armor:6,
				base_attack_cooldown:1700,
				base_strength:23,
				base_agility:17,
				base_intelligence:21
            }
        },
        goods: {
            1: {
                gname: "黑铁圣器",
				gimg:"images/wp1.png",
                formula:[],
                gattribute: {
							strength:1,
							agility:1,
							intelligence:1
							},
                effect: {
						uniq:'',
						uniqvalue:'',
						up:false ,
						grade:1
						},
                pay:53
            },
            2: {
                gname: "聚合魔棒",
				gimg:"images/wp2.png",
                formula:[],
                gattribute: {},
                effect: {
						uniq:'',
						uniqvalue:'',
						up:false ,
						grade:1
						},
                pay:200
            },
			3:{
				gname: "护戒",
				gimg:"images/wp3.png",
                formula:[],
                gattribute: {
							armor:2
							},
                effect: {
						uniq:'',
						uniqvalue:'',
						up:false ,
						grade:1
						},
                pay:175
			
			},
			4:{
				gname: "恢复坠饰",
				gimg:"images/wp4.png",
                formula:[],
                gattribute: {
							hp_r:2
							},
                effect: {
						uniq:'',
						uniqvalue:'',
						up:false ,
						grade:1
						},
                pay:350
			
			},
			5:{
				gname: "黄金天平",
				gimg:"images/wp5.png",
                formula:[3,4],
                gattribute: {
							armor:[3,4,5],
							hp_r:[2.5,3,3.5]
							
							},
                effect: {
						uniq:{
							name:'抗魔：魔抗+1/2/3',
							value:[1,2,3]
						},
						up:false,
						up_describe:"此物品可以通过购买配方升级，最多升至3级",
						grade:1
						},
                pay:800
			
			},
		},
		category:{
			0:[
			//所有的
			],
			1:[//消耗品
				2
			],
			2:[//移动速度
			
			],
			3:[//加强
				1,
			],
			4:[//攻击
				
			],
			
			5:[//攻击力
			],
			6:[//攻击速度
			],
			7:[//攻击特技
			],
			
			8:[//防御
				3,4,5
			],
			9:[//护甲
				3,5
			],
			10:[//生命回复
				4,5
			],
			11:[//生命上线
			
			],
			12:[//防御特技
			
			],
			13:[//魔法
				5
			],
			14:[//法力回复
			
			],
			15:[//法力上限
				
			],
			16:[//魔法特技
				5
			],
			
		},
        goodsval: function(gid) {
            var goodsv = arr.goods[gid];
            return goodsv;
        },
        roleval: function(rid) {
            var rolev = arr.role[roleid];
            return rolev;
        },
        minus: function(id) {
            var rolev = arr.zbval(id);
            result.a = result.a - rolev.a;
            result.b = result.b - rolev.b;
            result.c = result.c - rolev.c;
            result.e = result.d - rolev.d;
            alert(result.a + "," + result.b + "," + result.c + "," + result.d + "," + result.e);
        },
        add: function(id) {
            var rolev = arr.zbval(id);
            result.a = result.a + rolev.a;
            result.b = result.b + rolev.b;
            result.c = result.c + rolev.c;
            result.d = result.d + rolev.d;
            alert(result.a + "," + result.b + "," + result.c + "," + result.d + "," + result.e);
        },
		get_category_id:function(id){
			var idstr=arr.category[id];
			return  idstr;
		},
		goods_push:function(id){
			var idstr=arr.get_category_id(id);
			var goods_arr = new Array();
			for(var key in idstr) {
				goods_arr[key]=arr.goodsval(idstr[key]);
			}
			scan_array(goods_arr[0]);
		},
		
		
    };
	
	
	function scan_array(arr) {
		for(var key in arr) { // 这个是关键
			//if(typeof(arr[key]) == 'array' || typeof(arr[key]) == 'object') {// 递归调用
				//scan_array(arr[key]);
			//} else {
				document.write(key + ' = ' + arr[key] + '<br>');
			//}
		}
	}

</script>
